<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
   
<input type="checkbox" value="1" name="check" checked="checked" />
<input type="checkbox" value="2" name="check"  />
<input type="checkbox" value="3" name="check" checked="checked" />
<input type="checkbox" value="4" name="check"   />
<script>
    //遍历checkbox控件，输出选中个数
    
    $(':input').click(function(){
        var num=$(':checked');
        console.log(num.length);
    })
</script>
    
</body>
</html>